VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmthresholds 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Change Characters"
   ClientHeight    =   10815
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   8310
   Icon            =   "frmthresholds.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   10815
   ScaleWidth      =   8310
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin MSComDlg.CommonDialog comdlg 
      Left            =   120
      Top             =   120
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.OptionButton optbw 
      Caption         =   "Black and White Text"
      Height          =   255
      Left            =   3360
      TabIndex        =   21
      Top             =   840
      Width           =   2055
   End
   Begin VB.OptionButton optcolor 
      Caption         =   "Colored Text"
      Height          =   255
      Left            =   960
      TabIndex        =   20
      Top             =   840
      Value           =   -1  'True
      Width           =   1815
   End
   Begin VB.Frame gen 
      Caption         =   "Solid Color"
      Height          =   6495
      Left            =   240
      TabIndex        =   1
      Top             =   4080
      Width           =   7815
      Begin VB.ListBox colorlist 
         Height          =   3375
         Left            =   480
         TabIndex        =   12
         Top             =   2760
         Width           =   4215
      End
      Begin VB.ListBox charlist 
         Height          =   3375
         Left            =   4800
         TabIndex        =   11
         Top             =   2760
         Width           =   1335
      End
      Begin VB.PictureBox colorbox 
         Height          =   375
         Left            =   480
         ScaleHeight     =   315
         ScaleWidth      =   4155
         TabIndex        =   10
         Top             =   2040
         Width           =   4215
      End
      Begin VB.TextBox txtchar 
         Height          =   375
         Left            =   4800
         TabIndex        =   9
         Top             =   2040
         Width           =   1335
      End
      Begin Pic2Ascii.CandyButton add 
         Height          =   375
         Left            =   6240
         TabIndex        =   17
         Top             =   2040
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Add"
         IconHighLiteColor=   0
         CaptionHighLiteColor=   0
         Style           =   6
         Checked         =   0   'False
         ColorButtonHover=   14704640
         ColorButtonUp   =   13668448
         ColorButtonDown =   11108432
         BorderBrightness=   0
         ColorBright     =   16775930
         DisplayHand     =   0   'False
         ColorScheme     =   2
      End
      Begin Pic2Ascii.CandyButton remove 
         Height          =   375
         Left            =   6240
         TabIndex        =   18
         Top             =   2520
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Remove"
         IconHighLiteColor=   0
         CaptionHighLiteColor=   0
         Style           =   6
         Checked         =   0   'False
         ColorButtonHover=   14704640
         ColorButtonUp   =   13668448
         ColorButtonDown =   11108432
         BorderBrightness=   0
         ColorBright     =   16775930
         DisplayHand     =   0   'False
         ColorScheme     =   2
      End
      Begin Pic2Ascii.CandyButton save 
         Height          =   375
         Left            =   6240
         TabIndex        =   23
         Top             =   5280
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Save"
         IconHighLiteColor=   0
         CaptionHighLiteColor=   0
         Style           =   6
         Checked         =   0   'False
         ColorButtonHover=   14704640
         ColorButtonUp   =   13668448
         ColorButtonDown =   11108432
         BorderBrightness=   0
         ColorBright     =   16775930
         DisplayHand     =   0   'False
         ColorScheme     =   2
      End
      Begin Pic2Ascii.CandyButton load 
         Height          =   375
         Left            =   6240
         TabIndex        =   24
         Top             =   5760
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Load"
         IconHighLiteColor=   0
         CaptionHighLiteColor=   0
         Style           =   6
         Checked         =   0   'False
         ColorButtonHover=   14704640
         ColorButtonUp   =   13668448
         ColorButtonDown =   11108432
         BorderBrightness=   0
         ColorBright     =   16775930
         DisplayHand     =   0   'False
         ColorScheme     =   2
      End
      Begin VB.Label Label5 
         BackStyle       =   0  'Transparent
         Caption         =   "Character list:"
         Height          =   255
         Left            =   4800
         TabIndex        =   16
         Top             =   2520
         Width           =   1335
      End
      Begin VB.Label Label4 
         BackStyle       =   0  'Transparent
         Caption         =   "Color list:"
         Height          =   255
         Left            =   480
         TabIndex        =   15
         Top             =   2520
         Width           =   4215
      End
      Begin VB.Label Label3 
         BackStyle       =   0  'Transparent
         Caption         =   "Type character:"
         Height          =   255
         Left            =   4800
         TabIndex        =   14
         Top             =   1800
         Width           =   1335
      End
      Begin VB.Label Label2 
         BackStyle       =   0  'Transparent
         Caption         =   "Click to select color:"
         Height          =   255
         Left            =   480
         TabIndex        =   13
         Top             =   1800
         Width           =   4215
      End
      Begin VB.Label info2 
         BackStyle       =   0  'Transparent
         Caption         =   $"frmthresholds.frx":000C
         Height          =   1215
         Left            =   480
         TabIndex        =   2
         Top             =   360
         Width           =   6855
      End
   End
   Begin VB.Frame question 
      Caption         =   "Threshold"
      Height          =   2175
      Left            =   240
      TabIndex        =   0
      Top             =   1680
      Width           =   7815
      Begin VB.HScrollBar sensitivity 
         Height          =   255
         Left            =   600
         Max             =   255
         Min             =   1
         TabIndex        =   3
         Top             =   1680
         Value           =   1
         Width           =   4335
      End
      Begin VB.Label info1 
         BackStyle       =   0  'Transparent
         Caption         =   $"frmthresholds.frx":022F
         Height          =   855
         Left            =   480
         TabIndex        =   8
         Top             =   480
         Width           =   5535
      End
      Begin VB.Label lblsensitivity 
         BackStyle       =   0  'Transparent
         Caption         =   "Color Value + or - 1"
         Height          =   255
         Left            =   5040
         TabIndex        =   7
         Top             =   1680
         Width           =   1935
      End
      Begin VB.Label low 
         BackStyle       =   0  'Transparent
         Caption         =   "Low"
         Height          =   255
         Left            =   600
         TabIndex        =   6
         Top             =   1440
         Width           =   375
      End
      Begin VB.Label med 
         BackStyle       =   0  'Transparent
         Caption         =   "Medium"
         Height          =   255
         Left            =   2400
         TabIndex        =   5
         Top             =   1440
         Width           =   615
      End
      Begin VB.Label high 
         BackStyle       =   0  'Transparent
         Caption         =   "High"
         Height          =   255
         Left            =   4560
         TabIndex        =   4
         Top             =   1440
         Width           =   375
      End
   End
   Begin Pic2Ascii.CandyButton mkay 
      Height          =   615
      Left            =   6480
      TabIndex        =   19
      Top             =   600
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   1085
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "M'Kay"
      IconHighLiteColor=   0
      CaptionHighLiteColor=   0
      Style           =   6
      Checked         =   0   'False
      ColorButtonHover=   14704640
      ColorButtonUp   =   13668448
      ColorButtonDown =   11108432
      BorderBrightness=   0
      ColorBright     =   16775930
      DisplayHand     =   0   'False
      ColorScheme     =   2
   End
   Begin VB.Label info3 
      BackStyle       =   0  'Transparent
      Caption         =   $"frmthresholds.frx":0348
      Height          =   495
      Left            =   720
      TabIndex        =   22
      Top             =   240
      Width           =   5535
   End
End
Attribute VB_Name = "frmthresholds"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Const COL_DELIM = ".end colors"
Private Const CHR_DELIM = ".end chars"

Private Sub add_Click()
If txtchar.Text = vbNullString Then
    MsgBox "You need to enter a character to use with the color you chose.", vbExclamation, "No Character"
Else
    colorlist.AddItem colorbox.BackColor
    charlist.AddItem txtchar.Text
    colorbox.BackColor = &H8000000F
    txtchar.Text = vbNullString
End If
End Sub

Private Sub charlist_Click()
colorlist.ListIndex = charlist.ListIndex
colorbox.BackColor = colorlist.Text
End Sub

Private Sub colorlist_Click()
charlist.ListIndex = colorlist.ListIndex
colorbox.BackColor = colorlist.Text
End Sub

Private Sub Form_Load()
Dim i As Integer
If threshold <> 0 Then
    sensitivity.Value = threshold
    Call sensitivity_Scroll
    For i = 0 To UBound(theChars)
        colorlist.AddItem rgb(theChars(i).red, theChars(i).green, theChars(i).blue)
        charlist.AddItem theChars(i).Char
    Next i
End If
End Sub

Private Sub load_Click()
Dim ln As String
With comdlg
    .DialogTitle = "Open Color Presets File"
    .Filter = "Color Files (*.col)|*.col|"
    .Flags = cdlOFNHideReadOnly
    .ShowOpen
    If Len(.FileName) <> 0 Then
        Open .FileName For Input As #1
            Line Input #1, ln
            While ln <> COL_DELIM
                colorlist.AddItem ln
                Line Input #1, ln
            Wend
            Line Input #1, ln
            While ln <> CHR_DELIM
                charlist.AddItem ln
                Line Input #1, ln
            Wend
            Line Input #1, ln
            sensitivity.Value = Val(ln)
        Close #1
    End If
End With
End Sub

Private Sub remove_Click()
If colorlist.ListIndex = -1 Then
    MsgBox "Nothing to remove.", vbExclamation, vbNullString
Else
    colorlist.RemoveItem colorlist.ListIndex
    charlist.RemoveItem charlist.ListIndex
End If
End Sub

Private Sub save_Click()
Dim i As Integer
If colorlist.ListCount = 0 Then
    MsgBox "You need to make colors and characters before you can save anything.", vbExclamation, "No Data"
Else
    With comdlg
        .DialogTitle = "Save Color Presets File"
        .Filter = "Color Files (*.col)|*.col|"
        .ShowSave
        If Len(.FileName) <> 0 Then
            Open .FileName For Output As #1
                For i = 0 To colorlist.ListCount - 1
                    Print #1, colorlist.List(i)
                Next i
                Print #1, COL_DELIM
                For i = 0 To charlist.ListCount - 1
                    Print #1, charlist.List(i)
                Next i
                Print #1, CHR_DELIM
                Print #1, sensitivity.Value
            Close #1
        End If
    End With
End If
End Sub

Private Sub sensitivity_Change()
Call sensitivity_Scroll
End Sub

Private Sub sensitivity_Scroll()
lblsensitivity.Caption = "Color Value + or - " & sensitivity.Value
End Sub

Private Sub colorbox_Click()
txtchar.SetFocus
colorselector.Show
End Sub

Private Sub mkay_Click()
Dim pixelcolor As Long
Dim r, g, b As Integer
Dim i As Integer

If colorlist.ListCount = 0 Then
    MsgBox "You need to choose your colors and characters.", vbExclamation, "No Data"
Else
    ReDim theChars(colorlist.ListCount - 1)
    threshold = sensitivity.Value
    isColored = optcolor.Value

    For i = 0 To colorlist.ListCount - 1
        pixelcolor = Val(colorlist.List(i))
        r = &HFF& And pixelcolor
        g = (&HFF00& And pixelcolor) \ 256
        b = (&HFF0000 And pixelcolor) \ 65536
        theChars(i).red = r
        theChars(i).green = g
        theChars(i).blue = b
        theChars(i).Char = charlist.List(i)
    Next i
    Unload Me
End If
End Sub

Private Sub txtchar_Change()
If Len(txtchar.Text) = 2 Then
    txtchar.Text = Left(txtchar.Text, 1)
    txtchar.SelStart = 1
End If
End Sub

Private Sub txtchar_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then add_Click
End Sub
